package com.qf.mybatisplus.schedule;



import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import redis.clients.jedis.Jedis;

import java.io.IOException;
import java.util.HashMap;
import java.util.Set;

/**
 * @author: ZDD
 * @createDate: 2020年09月01日 17:47
 * @version: 1.0
 * @description: 窗口定时任务
 */
//@Configuration
//@EnableScheduling
public class MachineTask {

    private static final Jedis redis;
    static{
        redis = new Jedis("localhost", 6379);
//         redis.auth("moko123");
    }

    /**
     * 工作日时间，每5s执行一次
     */
    @Scheduled(cron = "0/5 * 9-20 * * ?")
    private void windowsFlush() throws IOException {

        System.err.println("我执行了");
        Set<String> keys = redis.keys("zsbh:*");
        HashMap<String,Object> map = new HashMap<>();
        HashMap<String,String> param = new HashMap<>();

        for (String key: keys) {
            Object value =redis.get(key);
            map.put(key,value);
            System.err.println(value);
        }

    }

    public static void main(String[] args) {
        Jedis redis  = new Jedis("localhost", 6379);
        System.err.println("我执行了");
        Set<String> keys = redis.keys("zsbh:*");
        HashMap<String,Object> map = new HashMap<>();
        HashMap<String,String> param = new HashMap<>();
        for (String key: keys) {
            Object value =redis.get(key);
            map.put(key,value);
            System.err.println(value);
        }
    }

}
